CC		= gcc
CFLAGS	= 
OBJ_DIR	= debug
INCLUDE = -I/code/unix-c/

TARGET 	= app
SRC		= main.c
APUE 	= /code/unix-c/apue.*

$(TARGET): $(SRC) $(OBJ_DIR)
	$(CC) $(APUE) $(INCLUDE) $< -o $(OBJ_DIR)/$@

all: $(basename $(wildcard *.c))

%: %.c $(OBJ_DIR)
	$(CC) $(APUE) $(INCLUDE) $< -o $(OBJ_DIR)/$@

$(OBJ_DIR): 
	[ ! -d $(OBJ_DIR) ] && mkdir $(OBJ_DIR) -p

.PHONY: clean
clean: 
	rm debug -rf
